#include "myfiledialog.h"
#include <QListView>
#include <QTreeView>
#include <QDialogButtonBox>
#include <QDebug>
#include "common.h"

MyFileDialog::MyFileDialog(QWidget *parent)
    : QFileDialog(parent)
{
    setOption(QFileDialog::DontUseNativeDialog, true);
    QListView *pListView = this->findChild<QListView*>("listView");
    if (pListView)
       pListView->setSelectionMode(QAbstractItemView::SingleSelection);
    QTreeView *pTreeView = this->findChild<QTreeView*>();
    if (pTreeView)
       pTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
    QDialogButtonBox *pButton = this->findChild<QDialogButtonBox *>("buttonBox");
    if (pButton)
    {
        LOG_QDEBUG << pButton;
    }

    disconnect(pButton, SIGNAL(accepted()), this, SLOT(accept()));//使链接失效
    connect(pButton, SIGNAL(accepted()), this, SLOT(on_choise()));//改成自己的槽
}

MyFileDialog::~MyFileDialog()
{

}

void MyFileDialog::on_choise()
{
    QDialog::accept();
}
